import axios from "axios";

const request = axios.create({
    baseURL: "http://localhost:8090",
    timeout: 3000
});

// to do 
request.interceptors.response.use(response => {

    const { code, message, success, data } = response.data;
    // console.log(code);
    // console.log(message);
    // console.log(success);
    // console.log(data);
    if (code !== 2000) {
        // 做点什么
    }
    // 其他判断
    return data;
}, error => {
    // 对响应错误做点什么 , 系统响应错误
    return Promise.reject(error);
})

export default request;
